package com.sgffsg.learn.javalib.algorithm.listnode;

/**
 * @author: lmk
 * @date: 2024/4/17
 * @desc:
 */
public class ReverseNode {

    public static void main(String[] args) {

    }

    public static ListNode reverse(ListNode head) {
        ListNode cur = head;
        ListNode pre = null;
        ListNode temp = null;
        while (cur != null) {
            temp = cur.next;
            cur.next = pre;
            pre = cur;
            cur = temp;
        }
        return pre;
    }

}
